package com.herui.iot.ui.evaluation;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.herui.sdyu_lib.adapter.recycle_view.base.ViewHolder;
import com.herui.sdyu_lib.utils.ToastUtil;
import com.herui.sport_care.R;
import com.herui.sport_care.data.eval.BeEvaluatedInfo;
import com.herui.sport_care.data.eval.EvalDetail;
import com.herui.sport_care.ui.BaseListSportActivity;

import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

/**
 * 评估详情页面
 */
public class EvalDetailActivity extends BaseListSportActivity<BeEvaluatedInfo> {

    private EvalPresenter evalPresenter;

    @BindView(R.id.id_recyclerview)
    RecyclerView recyclerView;
//    评估组别
    @BindView(R.id.tv_eval_group)
    TextView evalGroup;
//    评估时间
    @BindView(R.id.tv_eval_time)
    TextView evalTime;
//    评估方案
    @BindView(R.id.tv_eval_plan)
    TextView evalPlan;
//    评估协议
    @BindView(R.id.tv_eval_agreement)
    TextView evalAgreement;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle("评估方案名称详情");

        evalPresenter = new EvalPresenter(view);
    }

    @Override
    public int getLayout() {
        return R.layout.activity_eval_detail;
    }

    @Override
    public void initParam() {

        Intent intent = getIntent();
        int evalId = intent.getIntExtra("evalId", -1);
        if (evalId == -1) {
            ToastUtil.showMessage("参数错误");
            return;
        }

        initList(recyclerView, R.layout.item_eval_user, false, null);

        evalPresenter.getEvalDetail(evalId);

    }

    EvalPresenter.View view = new EvalPresenter.View() {
        @Override
        public void onEvalDetail(EvalDetail evalDetail) {
            // 其他数据初始化
            evalDetail.getName();
            evalGroup.setText(evalDetail.getName());
            evalTime.setText(evalDetail.getEvaluationDate()+ "  " +evalDetail.getEvaluationStartTime());
            evalPlan.setText(evalDetail.getBetaSchemeName());
            evalAgreement.setText(evalDetail.getAgreementName());

            // 用户列表初始化
            addData(evalDetail.getBeEvaluatedList());

        }
    };

    @Override
    protected void convert(ViewHolder holder, BeEvaluatedInfo value, int position) {
        holder.setText(R.id.tv_detail_number,value.getId()+"");
        holder.setText(R.id.tv_detail_group,value.getName());
        holder.setText(R.id.tv_detail_sex,value.getGender());
        holder.setText(R.id.tv_detail_age,value.getAge()+"");
    }

    @Override
    protected void doRefresh() {
    }
}